package main

import "fmt"

/**
定义变量的三种方式
*/
var global_int int = 10
var global_str = "hello"
/**
这种方式定义变量只允许用于函数体内
global_bool := true
*/

func main() {
	fmt.Println("global_int: ", global_int)
	fmt.Println("global_str: ", global_str)

	var block_code1 string = "000001.SZ"
	var block_code2 = "600000.SH"
	block_code3 := "600570.SH"

	fmt.Println(block_code1)
	fmt.Println(block_code2)
	fmt.Println(block_code3)

	/**
	在函数体内，变量可以先声明，然后在赋值
	*/
	var local_bool bool
	local_bool = true
	fmt.Println(local_bool)

	/**
	float类型只有float32和float64两种类型，没有float类型
	*/
	var local_float32 float32 = 1
	var local_float64 float64 = 2
	fmt.Println(local_float32)
	fmt.Println(local_float64)

	var b1 byte = 255
	fmt.Println(b1)

	/**
	编译报如下错误：
	cannot use 256 (untyped int constant) as byte value in variable declaration (overflows)
	因为byte类型等价于unit8，数据范围是0～255，定义时超过这个范围编译会报错
	var b2 byte = 256
	fmt.Println(b2)
	*/

	var ru rune = -2147483648
	fmt.Println("[func|main]run=", ru)

	var up uintptr = 100
	fmt.Println("[func|main]up=", up)
}